//
//  RecommendTableViewCell.m
//  EasyBuy
//
//  Created by Zhu Xiangjun on 10/5/12.
//  Copyright (c) 2012 shen donghao. All rights reserved.
//

#import "RecommendTableViewCell.h"
#import "ImageCacheSupport/ImageLoadView.h"

@interface RecommendTableViewCell(){
    ImageLoadView *loadView;
    UITextField   *titleFiled;
    UITextField   *priceFiled;
    UITextField   *officalpriceFiled;
    UITextField   *timeField;
    UITextField   *locationField;
}

@end

@implementation RecommendTableViewCell

-(void)dealloc{
    [super dealloc];
    [loadView release];
    [titleFiled release];
    [priceFiled release];
    [officalpriceFiled release];
    [timeField release];
    [locationField release];
}

-(void)initCellWithRecommendItemData:(RecommendItemData *)recommendItemData{
    [loadView setImageUrl:recommendItemData.image];
    titleFiled.text = recommendItemData.title;
    priceFiled.text = [NSString stringWithFormat:@"￥%d",recommendItemData.price];
    officalpriceFiled.text = [NSString stringWithFormat:@"￥%d",recommendItemData.officalprice];
    timeField.text = recommendItemData.time;
    locationField.text = recommendItemData.location;
    
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){

        ImageLoadView *_loadView = [[ImageLoadView alloc] initWithFrame:CGRectMake(10, 5, 60, 60)];
        loadView = _loadView;
        [self addSubview:loadView];
        [_loadView release];
        
        UITextField *_titleFiled = [[UITextField alloc] initWithFrame:CGRectMake(loadView.frame.origin.x+loadView.frame.size.width+10, 10, 220, 15)];
        _titleFiled.enabled = NO;
        _titleFiled.font = [UIFont systemFontOfSize:15.0f];
        _titleFiled.backgroundColor = [UIColor clearColor];
        titleFiled  = _titleFiled;
        [self addSubview:titleFiled];
        [_titleFiled release];
        
        UITextField *_priceField = [[UITextField alloc] initWithFrame:CGRectMake(loadView.frame.origin.x+loadView.frame.size.width+10, titleFiled.frame.origin.y+titleFiled.frame.size.height+8, 70, 16)];
        _priceField.enabled = NO;
        _priceField.font = [UIFont systemFontOfSize:15.0f];
        _priceField.textColor = [UIColor redColor];
        _priceField.backgroundColor = [UIColor clearColor];
        priceFiled = _priceField;
        [self addSubview:priceFiled];
        [_priceField release];
        
        UITextField *_offcialpriceField = [[UITextField alloc] initWithFrame:CGRectMake(priceFiled.frame.origin.x+priceFiled.frame.size.width+10, titleFiled.frame.origin.y+titleFiled.frame.size.height+10, 70, 15)];
        _offcialpriceField.enabled = NO;
        _offcialpriceField.font = [UIFont systemFontOfSize:13.0f];
        _offcialpriceField.backgroundColor = [UIColor clearColor];
        officalpriceFiled = _offcialpriceField;
        [self addSubview:officalpriceFiled];
        [_offcialpriceField release];
        
        UITextField *_timeField = [[UITextField alloc] initWithFrame:CGRectMake(loadView.frame.origin.x+loadView.frame.size.width+10, 52, 220, 20)];
        _timeField.enabled = NO;
        _timeField.font = [UIFont systemFontOfSize:12.0f];
        _timeField.backgroundColor = [UIColor clearColor];
        timeField = _timeField;
        [self addSubview:timeField];
        [_timeField release];
        
        UITextField *_locationField = [[UITextField alloc] initWithFrame:CGRectMake(260, 52, 50, 20)];
        _locationField.enabled = NO;
        _locationField.font = [UIFont systemFontOfSize:12.0f];
        _locationField.backgroundColor = [UIColor clearColor];
        locationField = _locationField;
        [self addSubview:locationField];
        [_locationField release];
        
        UIImage *image = [UIImage imageNamed:@"common_arrow_right.png"];
        UIImageView *_arrowRightView = [[UIImageView alloc] initWithFrame:CGRectMake(300, (70-image.size.height)/2, image.size.width, image.size.height)];
        [_arrowRightView setImage:image];
        [self addSubview:_arrowRightView];
        [image release];
        [_arrowRightView release];
        
        [self.contentView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"common_item_bg"]]];
        
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

}

@end
